<?php

	/**
	* @author Robbie Vasquez
 	* @author Matt Kennedy
 	*/
	
class Main extends Controller {

	function Main()
	{
		parent::Controller();	
	}
	
	function index()
	{
		$this->load->view('index');
	}
	
	//creating a function for the login process
	function login()
	{
		$this->load->model('Login');
		
		$log = $this->Login->process();	
		
		$data['log'] = $log;
		
		$this->load->view('index', $data);
	}
	
	//creating function for the logout process
	function logout()
	{
		$this->load->model('Sessions');
		
		$this->Sessions->logged_in();
		
		session_destroy();
		unset($_SESSION);
		
		header("Location: /runningrecords/");
		
	}
	
	//creating function for user to register
	function register()
	{
		$this->load->model('Register');
		
		$data = array();
		
		$errors = $this->Register->process();
		
		$data['errors'] = $errors;
				
		$this->load->view('index', $data);
	}
	
	//creating function for home page when user is logged in
	function home()
	{
		$this->load->model('Sessions');
		
		$this->Sessions->logged_in();
		
		$this->load->model('Stats');
		
		$info = $this->Stats->data();
		
		$stats = array();
		$stats['info'] = $info;
		
		$this->load->view('home', $stats);
	}
	
	function files()
	{
		$this->load->model('Sessions');
		
		$this->Sessions->logged_in();
		
		$this->load->model('Files');
		
		$files = $this->Files->docs();
		
		$docs = array();
		$docs['files'] = $files;
		
		$this->load->view('files', $docs);
	}
	
	function recover()
	{
		$this->load->model('Recover');
		
		$info = $this->Recover->check();
		
		$recover = array();
		$recover['info'] = $info;
		
		$this->load->view('recover', $recover);
	}
	
}